﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class DialogueManager : MonoBehaviour
{

    public GameObject dialoguePanel;        // 对话框画布
    public Text contentText;                // 对话框内容
    public Text dialogueNameText;           // 对话者名字

    [Header("对话内容")]
    public int currentLine;
    [TextArea]
    public List<string> dialogueContent;

    void Start()
    {
        currentLine = 0;
    }

    void Update()
    {
        ShowLine();
    }


    void ShowLine()
    {
        if (!dialoguePanel.activeInHierarchy)
        {
            return;
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (currentLine >= dialogueContent.Count)
            {
                dialoguePanel.SetActive(false);
                return;
            }
            contentText.text = dialogueContent[currentLine];
            currentLine++;
        }
    }
}
